<template>
  <div>
    <el-dialog
        title="审核"
        :close-on-click-modal="false"
        :visible.sync="visible"
        @close="formReset"
    >
      <el-form ref="form" :model="form" label-width="80px">
        <div class="end">
          <h3>请选择审核结果：</h3>
          <template>
            <el-form-item prop="radio" label="审核意见">
              <el-radio v-model="form.state" :label="true">审核通过</el-radio>
              <el-radio v-model="form.state" :label="false">审核不通过</el-radio>
            </el-form-item>
          </template>
          <el-form-item prop="auditOpinion" label="审核意见">
            <el-input type="textarea" placeholder="请输入审核意见" v-model="form.auditOpinion"/>
          </el-form-item>
        </div>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">提交审核结果</el-button>
          <el-button @click="cancel">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    id: {
      type: Number,
      default: 0
    },
    // visible: {
    //   type: Boolean,
    //   default: false
    // }
  },
  data() {
    return {
      visible: true,
      form: {
        state: false,
        auditOpinion: '',
        id: this.id
      }
    }
  },
  methods: {
    cancel() {
      this.$emit('cancelVisible');
    },
    formReset() {
      this.form = {
        radio: false,
        auditOpinion: ''
      };
      this.$emit('cancelVisible');
    },
    onSubmit() {
      this.$http({
        url: this.$http.adornUrl(`/reportapproval/conscheckrecord/audit`),
        method: 'post',
        data: this.form
      }).then((data) => {
        console.log(data);
        if (data && data.code === 0) {
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.$emit('cancelVisible');
              this.$emit('refreshDataList');
            }
          })
        } else {
          this.$message.error(data.msg)
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>

</style>